package com.sss.gsb.web.actions.page.download;

import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.struts2.convention.annotation.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionSupport;
import com.sss.gsb.util.ClassPathResourceUtil;

@Result(name = "success", type = "stream", params = { "contentType",
		"application/octet-stream", "inputName", "inputStream",
		"contentDisposition", "attachment;filename=\"loan_message.zip\"",
		"bufferSize", "1024" })
public class LoanSchemaAction extends ActionSupport {
	private static final String SCHEMAS_FILE = "classpath:download/loan_message.zip";
	private static final Logger log = LoggerFactory.getLogger(LoanSchemaAction.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = -5952634221627112947L;
	private InputStream inputStream;

	public InputStream getInputStream() {
		return inputStream;
	}

	public String execute() throws Exception {
		log.info("{ downloading... schemas...}");
		inputStream = new FileInputStream(ClassPathResourceUtil.getFileFromResource(SCHEMAS_FILE));
		return SUCCESS;
	}
}
